package cn.alog.utils;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

public class EsUtils {

    public static RestHighLevelClient getClient() {
        //设置服务器地址
        HttpHost host = new HttpHost("127.0.0.1", 9200);
        //构建客户端
        RestClientBuilder builder = RestClient.builder(host);
        //连接客户端
        RestHighLevelClient client = new RestHighLevelClient(builder);
        //返回
        return client;
    }
}
